package io.zso.dto;

import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.zso.commons.tools.utils.TreeNode;
import io.zso.commons.tools.validator.group.AddGroup;
import io.zso.commons.tools.validator.group.DefaultGroup;
import io.zso.commons.tools.validator.group.UpdateGroup;
import lombok.Data;
import org.hibernate.validator.constraints.Range;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * 菜单管理
 *
 * @author hp@zso.io
 * @since 1.0.0
 */
@Data
@ApiModel(value = "菜单管理")
public class SysMenuDTO extends TreeNode<SysMenuDTO> implements Serializable {
    private static final long serialVersionUID = 1L;

	@ApiModelProperty(value = "id")
	@Null(message="{id.null}", groups = AddGroup.class)
	@NotNull(message="{id.require}", groups = UpdateGroup.class)
	private Long id;

	@ApiModelProperty(value = "上级ID")
	@NotNull(message="{sysmenu.pid.require}", groups = DefaultGroup.class)
	private Long pid;

	@ApiModelProperty(value = "菜单名称")
	private String title;

	@ApiModelProperty(value = "菜单简称")
	private String shortTitle;

	@ApiModelProperty(value = "路由名称(英文)")
	private String name;

	@ApiModelProperty(value = "菜单地址")
	private String path;

	@ApiModelProperty(value = "前端组件")
	private String component;

	@ApiModelProperty(value = "重定向地址")
	private String redirect;

	@ApiModelProperty(value = "是否显示")
	private Boolean hidden;

	@ApiModelProperty(value = "类型  0：菜单   1：按钮")
	@Range(min=0, max=1, message = "{sysmenu.type.range}", groups = DefaultGroup.class)
	private Integer type;

	@ApiModelProperty(value = "菜单图标")
	private String icon;

	@ApiModelProperty(value = "权限标识，如：sys:menu:save")
	private String permissions;

	@ApiModelProperty(value = "排序")
	@Min(value = 0, message = "{sort.number}", groups = DefaultGroup.class)
	private Integer sort;

	@ApiModelProperty(value = "扩展配置，标准json格式")
	private String extraConfig;

	@ApiModelProperty(value = "上级菜单名称")
	private String parentTitle;

	@ApiModelProperty(value = "[批量]按钮名称")
	private List<String> batchTitles;
	@ApiModelProperty(value = "[批量]按钮权限")
	private List<String> batchPermissions;

	@ApiModelProperty(value = "创建时间")
	@JsonProperty(access = JsonProperty.Access.READ_ONLY)
	private Date createDate;

	@ApiModelProperty(value = "上级菜单名称")
	private String parentName;

	@Override
	public Long getId() {
		return id;
	}

	@Override
	public void setId(Long id) {
		this.id = id;
	}

	@Override
	public Long getPid() {
		return pid;
	}

	@Override
	public void setPid(Long pid) {
		this.pid = pid;
	}
}
